<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8"/>
        <title>使用arcTo和arc方法绘制圆弧</title>
        <meta name="auther" content="wangjiale"/>
        <style>
            canvas{border:thin solid black; margin:4px;}
            body>*{float: left;}
        </style>
    </head>
    <body>
        <canvas id="canvas" width="500" height="140">
            Your browser doesn't support the <code>canvas</code> element.
        </canvas>
        <script>
            var ctx=document.getElementById("canvas").getContext("2d");

            var point1=[100,10];
            var point2=[200,10];
            var point3=[200,110];


            ctx.fillStyle="yellow";
            ctx.strokeStyle="black";
            ctx.lineWidth=4;

            ctx.beginPath();
            ctx.moveTo(point1[0],point1[1]);
            ctx.arcTo(point2[0],point2[1],point3[0],point3[1],100);
            ctx.stroke();

            ctx.beginPath();
            //true是逆时针方向绘制，false是顺时针方向绘制,角度是顺时针方向
            ctx.arc(300,60,50,0,Math.PI/2,true);
            ctx.fill();
            ctx.stroke();

            ctx.beginPath();
            ctx.arc(430,60,50,Math.PI/2,Math.PI,false);
            ctx.fill();
            ctx.stroke();


            drawPoint(point1[0],point1[1]);
            drawPoint(point2[0],point2[1]);
            drawPoint(point3[0],point3[1]);

            ctx.beginPath();
            ctx.moveTo(point1[0],point1[1]);
            ctx.lineTo(point2[0],point2[1]);
            ctx.lineTo(point3[0],point3[1]);
            ctx.stroke();

            function drawPoint(x,y){
                ctx.lineWidth=1;
                ctx.strokeStyle="red";
                ctx.strokeRect(x-2,y-2,4,4);
            }
        </script>
    </body>
</html>